# Maintainer: Luca Weiss <luca@z3ntu.xyz>
# Contributor: Brandon Boese <brandonboese@protonmail.com>
pkgname=repowerd
pkgver=2023.07
pkgrel=0
pkgdesc="Power daemon to monitor and control system power state"
url="https://gitlab.com/ubports/development/core/repowerd"
arch="all !s390x" # blocked by libgbinder
license="LGPL-3.0-only"
makedepends="
	cmake
	cmake-extras
	glib-dev
	gmock
	gtest-dev
	libgbinder-dev
	lomiri-deviceinfo-dev
	qt5-qtbase-dev
	samurai
	"
checkdepends="dbus"
subpackages="$pkgname-openrc"
source="https://gitlab.com/ubports/development/core/repowerd/-/archive/$pkgver/repowerd-$pkgver.tar.gz
	repowerd.initd
	0001-dbus-Remove-at_console-filtering.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DREPOWERD_ENABLE_HYBRIS=False
	cmake --build build
}

check() {
	# Test ARealFilesystem.performs_ioctl in repowerd-adapter-tests fails
	# https://gitlab.com/ubports/development/core/repowerd/-/issues/41
	ctest --test-dir build --output-on-failure -E repowerd-adapter-tests
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
2cbf879956e049c6c197516c23e43bfeafee13f0e354dbf0032f7a9b97bf849255d5dd204f4178759837fd06601fc9ebbdf3a409af3d79da1fe8b3a9c77bb059  repowerd-2023.07.tar.gz
d8c4dd351a7bf2bcc66b0eb8b0d17d602661f7defb857be5a28f694e4977b634b7d101f738058ce0ccaa313c4e316f7222c753610500ddbd68f8e42de7c57f29  repowerd.initd
f6212991bd4ea6704a74f71615fa5d0b9b738144c2448f03d90a0d2c6dd320e17c3c070add7f7877ca3f6f4c2526d44dd5277f8cefbd05ad08d99204c61d6766  0001-dbus-Remove-at_console-filtering.patch
"
